package me.ZFC.Text;

import java.util.Scanner;

public class Test6 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个手机号码");
        String phone;
        while (true) {
            phone = scanner.nextLine();
            if (phone.length() == 11) {
                break;
            } else {
                System.out.println("输入的号码有误");
            }
        }
        String newPhone = getPhone(phone);
        System.out.println(newPhone);
    }

    public static String getPhone(String phone) {
        String newPhone = "";
        for (int i = 0; i < phone.length(); i++) {
            char c = phone.charAt(i);
            if (i >= 3 && i <= 6) {
                newPhone = newPhone + "*";
            } else {
                newPhone = newPhone + c;
            }
        }
        return newPhone;
    }
}
